﻿Imports System.Windows.Forms
Public Class DlgCancelPROrder
    Dim Strsql As String
    Dim Mysql As New ClsSQLhelper
    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        'Strsql = "update prorder set orderstatus = 3,canceltype = " & Me.CboCancelType.SelectedValue & ",cancelnote = '" & Me.TxtCancelNote.Text & "',canceldatetime = '" & Pn_Framework.MysqlDateTimeFormat(Me.DTPCancelDate.Value, True) & "',cancelby = '" & Me.TxtCanceluser.Text & "' where ordernumber = '" & Me.TxtPrOrder.Text & "'"
        'Mysql.MySQLExecute(Strsql)
        MsgBox("รายการนี้ถูกยกเลิกแล้ว", MsgBoxStyle.Information)
        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Private Sub DlgCancelPROrder_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Strsql = "Select * from cancelordertype"
        Dim DTcancelordertype As New DataTable
        DTcancelordertype = Mysql.GetMYSQLDataTable(Strsql, "cancelordertype")
        With CboCancelType
            .DataSource = DTcancelordertype
            .DisplayMember = "canceltypename"
            .ValueMember = "canceltypeid"
        End With
        Dim DTPRorder As New DataTable
        Strsql = "select * from prorder where ordernumber = '" & Me.TxtPrOrder.Text & "'"
        DTPRorder = Mysql.GetMYSQLDataTable(Strsql, "prorder")

        Me.TxtCanceluser.Text = DTPRorder.Rows(0).Item("cancelby").ToString
        Me.DTPCancelDate.Value = DTPRorder.Rows(0).Item("canceldatetime")
        Me.TxtCancelNote.Text = DTPRorder.Rows(0).Item("cancelnote").ToString
        Me.CboCancelType.SelectedValue = DTPRorder.Rows(0).Item("canceltype")
        DTPRorder.Dispose()
    End Sub
End Class
